package com.cqgc.mapper;

import com.cqgc.pojo.entity.ShoppingCart;
import com.cqgc.pojo.vo.ShoppingCartVO;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ShoppingCartMapper {


    @Select("select * from shopping_cart where uid = #{uid}")
    Page<ShoppingCart> showShoppingCart(int uid);

    @Insert("insert into shopping_cart(gid,uid,quantity,provider_id) values(#{gid},#{uid},#{quantity},#{providerId})")
    void add(ShoppingCart shoppingCart);

    @Select("select * from shopping_cart where gid = #{gid} and uid = #{uid}")
    ShoppingCart findByGid(int gid,int uid);

    @Update("update shopping_cart set quantity = #{quantity} where gid = #{gid} and uid=#{uid}")
    void update(ShoppingCart shoppingCart);

    @Delete("delete from shopping_cart where uid = #{uid}")
    void cleanShoppingCart(int uid);

    @Delete("delete from shopping_cart where gid = #{gid} and uid = #{uid}")
    void deleteByGid(ShoppingCart shoppingCart);

    @Update("update shopping_cart set quantity = #{quantity} where gid = #{gid} and uid = #{uid}")
    void updateQuantity(ShoppingCart shoppingCart);


    int deleteByGidS(List<Integer> gids);
}
